# 定义参数名称
filename=kkFileView
giturl=https://gitee.com/lixingwu/file-online-preview.git

# 1. 下载主分支代码覆盖现有代码
# 如果不存在文件夹就下载，否则更新
if [ ! -d $filename ]; then
	echo -e "\033[33m下载代码中\033[0m"
	git clone -b master $giturl
else
	echo -e "\033[33m更新代码中\033[0m"
	cd ./$filename
	git pull
fi

# 2. 重启nginx
if [ $? -eq 0 ]; then
	systemctl restart nginx.service
	echo -e "\033[42;37m代码$filename更新成功\033[0m"
else
	echo -e "\033[41;37m代码$filename更新失败\033[0m"
fi